<?php


namespace coco;


use coco\traits\Singleton;

/**
 * 注册树
 * Class Tree
 * @package coco
 */
class Tree
{
    use Singleton;

    protected $tree = [];

    public function set($name, $obj)
    {
        $this->tree[$name] = $obj;
    }

    public function get($name)
    {
        return $this->tree[$name] ?? null;
    }

    public function has($name): bool
    {
        return array_key_exists($name, $this->tree);
    }
}